<template>
	<view class="container">
		<view class="zx-list">
			<view class="zx-item" v-for="(item,index) in zixunList" :key="index" @click="zxdetail(item.id)">
				<view class="zx-item-l">
					<view class="zx-item-lText">
						<text>{{item.title}}</text>
					</view>
					<view class="zx-item-lshuju">
						<view class="zx-item-lshuju-c">
							<view class="zx-item-lshuju-cicon">
								<image src="../../static/ic_coll.png" mode="widthFix"></image>
							</view>
							<text class="zx-item-lshuju-cnum">{{item.collect_num}}</text>
						</view>
						<view class="zx-item-lshuju-c">
							<view class="zx-item-lshuju-cicon">
								<image src="../../static/ic_eye.png" mode="widthFix"></image>
							</view>
							<text class="zx-item-lshuju-cnum">{{item.view_num}}</text>
						</view>
					</view>
				</view>
				<view class="zx-item-r">
					<image :src="item.image" mode="widthFix"></image>
				</view>
			</view>
		</view>
		<Patient-footer-bar :selected="3"></Patient-footer-bar>
	</view>
</template>

<script>
	import app from '../../App.vue';
	export default{
		data(){
			return{
				zixunList:[],
				page:1
			}
		},
		onLoad() {
			this.getzixunList()
		},
		onShow() {
			
		},
		onReachBottom(){
			let newpage = this.page
			newpage++;
			this.page=newpage;
			this.getzxlist()
			console.log(this.page)
		},
		methods: {
			getzixunList(){					//资讯列表
				let that = this,
					data = {
					page:that.page,
					per_page:10
				}
				app.post('api/article/lis',data).then(res=>{
					if(res.code == 1 && res.data.data != ''){
						that.zixunList = res.data.data
						if(that.page>1){
							if(res.data.data.length == 0){
								uni.showToast({
									title:'没有更多了~',
									icon:'none'
								})
							}
						}
					}
				})
			},
			zxdetail(id){						//资讯详情
				uni.showLoading({
					title:'加载中',
					success() {
						setTimeout(function(){
							uni.hideLoading({
								success:res=>{
									uni.navigateTo({
										url:'/pages/zixun/detail?id='+id
									})
								}
							})
						},1300)
					}
				})
			}
		}
	}
</script>

<style>
	@import url("../../common/zixun.css");
</style>
